#ifndef __AP_DISPLAY_H__
#define __AP_DISPLAY_H__

#include "customer.h"

#define TFT_BUF_NUM				4
#define ROTATE_BUF_NUM			1
#define DISPLAY_BUF_NUM			(TFT_BUF_NUM + ROTATE_BUF_NUM)

#define DRAW_BOUNDARY_CHECK		0

typedef enum
{
	SHOW_TIME_NONE,
	SHOW_TIME_RECORD,
	SHOW_TIME_BROWSE
} SHOW_TIME_TYPE;

#define BLUE_COLOR		0x001F
#define BLUE1_COLOR		0x87BE
#define RED_COLOR		0xF800
#define WHITE_COLOR		0xFFFF
#define BLACK_COLOR		0x0000
#define WARN_STR_COLOR	WHITE_COLOR

#define GENERAL_BLUE 0x467f//0x051d
typedef struct
{
	INT8U	line;
	struct
	{
		INT8U	y;
		INT8U	u;
		INT8U	v;
	}	color;
} PadColor;

typedef struct
{
	INT32U base;
	INT32U offset;
	struct
	{
		PadColor	top;
		PadColor	bottom;
		PadColor	left;
		PadColor	right;
	}	padding;	
	
} DISP_T, *DISP_P;

typedef DISP_P DISP_QUEUE[DISPLAY_BUF_NUM];

typedef INT32S (*DISP_EXTRA_FUN_T)(DISP_P frame);

extern INT16U		display_frame_pool_size;
extern DISP_T		display_frame_pool[DISPLAY_BUF_NUM];
extern DISP_QUEUE	display_rotate_queue;
extern DISP_QUEUE	display_free_queue;
extern DISP_QUEUE	display_ready_queue;
extern DISP_P		display_frame_tft;
extern DISP_P		display_frame_rot_keep;

typedef struct
{
	void (*ap_display_buff_copy_and_draw_ptr)(DISP_P frame_show, INT32U src_type);
	void (*ap_display_vblank_isr_ptr)(void);
} Overlap_Dispaly_Function;

//===============progress bar======================s
#define DPT_SHOW_NONE	0
#define DPT_SHOW_MP3	1
#define DPT_SHOW_RECORD	2
#define DPT_SHOW_BROWSE	3
extern void ap_display_play_time_draw(INT16U *frame_buff, INT16S x, INT16S y, INT32S current_t, INT32S total_t);
//=================================================o


 void		ap_display_init(void);
extern void		ap_display_effect_init(void);
extern void		ap_display_icon_sts_set(INT32U msg);
extern void		ap_display_icon_sts_clear(INT32U msg);
extern void		ap_display_draw(INT16U *buf);
extern INT16U	ap_display_digital_draw(INT16U *buf, INT8U digital, INT16U pos_x, INT16U pos_y, INT8U red_flag);
extern void		ap_display_buff_copy_and_draw(DISP_P frame_show, INT32U src_type);
extern void		ap_display_buff_copy_and_draw_TP(DISP_P frame_show, INT32U src_type);
extern void		ap_display_vblank_isr_TP(void);
extern void		Icon_size_change_TP(void);
extern void		ap_display_vblank_isr(void);
extern void		ap_display_timer(void);
extern void		ap_display_effect_draw(INT32U buff_addr);
extern void		ap_display_effect_draw1(INT32U buff_addr);
extern void		ap_display_effect_draw2(INT32U buff_addr);

extern void		ap_display_string_draw(STR_ICON *str_info);
extern void		timer_counter_force_display(INT8U force_en);
extern void		ap_display_string_icon_clear_all(void);
extern void		ap_display_left_rec_time_draw(INT32U time, INT8U flag);
extern INT32U	ap_display_timer_rec_time_get(void);
extern void		timer_counter_force_display_browser(INT8U force_en);
extern void		ap_display_show_date_time(SHOW_TIME_TYPE type);
extern void		ap_check_icon_infor(DISPLAY_ICONSHOW *icon_info);
extern INT32U	getDispDevBufSize(void);
extern DISP_P	ap_display_queue_get(DISP_QUEUE queue);
extern INT32S	ap_display_queue_put(DISP_QUEUE queue, DISP_P data);
extern DISP_P	ap_display_queue_query(DISP_QUEUE queue);
extern void		ap_display_icon_draw(INT16U *frame_buff, INT16U *icon_stream, DISPLAY_ICONSHOW *icon_info);
extern void		ap_display_str_icon_draw(INT16U *frame_buff);
extern void		ap_display_string_icon_start_draw(STR_ICON_EXT *str_info);
extern void		ap_display_string_icon_clear(STR_ICON_EXT *str_info);
extern INT8U	ap_display_line_mode_get(void);
extern void		ap_display_rec_time_draw(INT16U *frame_buff, void *time_ptr, INT16S pos_x_offset, INT16S pos_y_offset, INT8U red_flag);
extern void		ap_display_rec_date_time_draw(INT16U *frame_buff);
extern void		ap_display_line_mode_set(INT8U mode);
extern void		ap_disply_draw_line(INT16U *drawImg, INT8U mode);
extern void		ap_display_rotate_buf(INT32U buf_in, INT32U buf_out, INT8U busy_wait, void (*isr_hook)(void));

extern INT8U*	ap_Get_GP420_Data(INT32U line_num,INT32U get_data_position_x  ,INT8U *buf,INT16U buf_w,INT32U cnt);
extern void		ap_Put_GP420_Data(INT32U line_num,INT32U put_data_position_x  ,INT8U *buf, INT16U buf_w ,INT8U *data_stream , INT16U icon_w);

extern INT16U*	ap_Get_GP420_Data_1(INT32U line_num,INT32U get_data_position_x  ,INT16U *buf,INT16U buf_w,INT32U cnt);
extern void		ap_Put_GP420_Data_1(INT32U line_num,INT32U put_data_position_x  ,INT16U *buf, INT16U buf_w ,INT16U *data_stream , INT16U icon_w);

extern void		ap_RGB_Transfer_GP420(INT16U RGB,INT32S *Y,INT32S *U,INT32S *V);
extern void		ap_RGB_To_GP420(INT32U R ,INT32U G , INT32U B,INT32S *Y,INT32S *U,INT32S *V);
extern void		ap_SeprateRGB(INT16U RGB,INT32U *r , INT32U *g ,  INT32U *b  );
extern void		ap_CPU_Fill_420FORMAT_Type1(INT16U tft_width, INT16U img_width, INT16U img_height, INT8U fill_val_y, INT8U fill_val_u, INT8U fill_val_v, INT32U buf_addr);
extern void		ap_display_register_release_fun(DISP_EXTRA_FUN_T fun);
extern void		ap_display_clear_screen(INT32U buf);
extern void		overlap_dispaly_function_initial(void);

extern void		ap_display_rotate_restart(void);
extern INT8U	ap_display_rotate_busy(void);

#if DRAW_BOUNDARY_CHECK
extern INT8U	ap_draw_boundary_check(INT8U *frame_buff ,INT8U *write_addr);
#endif

#endif
